package com.weakteam.orderonline.administratorconsole.spring;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.view.InternalResourceViewResolver;


/**
 *
 * @author Nail
 */

@EnableWebMvc
@ComponentScan(basePackages= {"com.weakteam.orderonline.administratorconsole.web"})
@Configuration
public class DispatcherConfig extends WebMvcConfigurerAdapter {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/index/**").addResourceLocations("/index/").setCachePeriod(31556926);
        registry.addResourceHandler("/res/**").addResourceLocations("/res/").setCachePeriod(31556926);
    }

    @Bean
    public InternalResourceViewResolver configureInternalResourceViewResolver()
    {
        InternalResourceViewResolver resolver = new InternalResourceViewResolver();
        resolver.setPrefix("/views/");
        resolver.setSuffix(".jsp");
        return resolver;
    }

}
